using AZROLESLib;

namespace AzManContrib.MVC.Decorators
{
    public class AzManClientContextDecorator : IAzManClientContext
    {
        private readonly IAzClientContext _surrogate;

        public AzManClientContextDecorator(IAzClientContext surrogate)
        {
            _surrogate = surrogate;
        }

        public object AccessCheck(string bstrObjectName, object varScopeNames, object varOperations, object varParameterNames, object varParameterValues, object varInterfaceNames, object varInterfaceFlags, object varInterfaces)
        {
            return _surrogate.AccessCheck(bstrObjectName, varScopeNames, varOperations, varParameterNames, varParameterValues,
                                   varInterfaceNames, varInterfaceFlags, varInterfaces);
        }

        public string GetBusinessRuleString()
        {
            return _surrogate.GetBusinessRuleString();
        }

        public object GetProperty(int lPropId, object varReserved)
        {
            return _surrogate.GetProperty(lPropId, varReserved);
        }

        public object GetRoles(string bstrScopeName = "")
        {
            return _surrogate.GetRoles(bstrScopeName);
        }

        public string UserDn
        {
            get { return _surrogate.UserDn; }
        }

        public string UserSamCompat
        {
            get { return _surrogate.UserSamCompat; }
        }

        public string UserDisplay
        {
            get { return _surrogate.UserDisplay; }
        }

        public string UserGuid
        {
            get { return _surrogate.UserGuid; }
        }

        public string UserCanonical
        {
            get { return _surrogate.UserCanonical; }
        }

        public string UserUpn
        {
            get { return _surrogate.UserUpn; }
        }

        public string UserDnsSamCompat
        {
            get { return _surrogate.UserDnsSamCompat; }
        }

        public string RoleForAccessCheck
        {
            get { return _surrogate.RoleForAccessCheck; }
            set { _surrogate.RoleForAccessCheck = value; }
        }

        public bool AccessCheck(IAzOperation operation)
        {
            object[] result = (object[])_surrogate.AccessCheck("Auditstring", new object[1], new object[] { operation.OperationID }, null, null, null, null, null);
            return (int)result[0] == 0;
        }
    }
}